package top.boking.server.socket;

import com.corundumstudio.socketio.Configuration;
import com.corundumstudio.socketio.SocketIOServer;
import com.corundumstudio.socketio.Transport;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

@Component
public class SocketIOConfig {
    
    @Bean
    public SocketIOServer socketIOServer() {
        Configuration config = new Configuration();
        config.setHostname("localhost");
        config.setPort(30000);
        config.setOrigin("*");
        
        // 添加关键配置
        config.setPingTimeout(25000);
        config.setPingInterval(25000);
        config.setUpgradeTimeout(10000);
        
        // 设置传输方式
        config.setTransports(Transport.WEBSOCKET, Transport.POLLING);
        
        return new SocketIOServer(config);
    }
}